<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        :root {
            --h: 50px;
            --w: 120px;
        }
        body {
            margin: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: rgb(217, 161, 240);
        }

        .navigation {
            font-size: 16px;
        }

        ul, li {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        ul.first-menu {
            height: var(--h);
            display: flex;
            justify-content: center;
            background-color: transparent;
            color: black;
            cursor: pointer;
            user-select: none;
        }
        ul.first-menu:hover {
            background-color: #fff;
            color: black;
        }

        li.first-menuitem {
            height: var(--h);
            width: var(--w);
            line-height: var(--h);
            text-align: center;
        }
        li.first-menuitem:hover {
            background-color: #fafafa;
            color: #0052d9;
        }

        ul.second-menu {
            background-color: #f5f5f5;
        }
        li.second-menuitem {
            height: 0;
            opacity: 0;
            transition: .3s;
            line-height: var(--h);
        }
        li.first-menuitem:hover li.second-menuitem {
            height: var(--h);
            opacity: 1;
            color: #000;
        }
        li.first-menuitem:hover li.second-menuitem:hover {
            background-color: #fff;
            color: #0052d9;
        }
    </style>
</head>
<body>
    <nav class="navigation">
        <ul class="first-menu">
            <li class="first-menuitem">菜单项1
                <ul class="second-menu">
                    <li class="second-menuitem">子菜单项1</li>
                    <li class="second-menuitem">子菜单项2</li>
                    <li class="second-menuitem">子菜单项3</li>
                    <li class="second-menuitem">子菜单项4</li>
                    <li class="second-menuitem">子菜单项5</li>
                </ul>
            </li>
            <li class="first-menuitem">菜单项2
                <ul class="second-menu">
                    <li class="second-menuitem">子菜单项1</li>
                    <li class="second-menuitem">子菜单项2</li>
                    <li class="second-menuitem">子菜单项3</li>
                    <li class="second-menuitem">子菜单项4</li>
                </ul>
            </li>
            <li class="first-menuitem">菜单项3
                <ul class="second-menu">
                    <li class="second-menuitem">子菜单项1</li>
                    <li class="second-menuitem">子菜单项2</li>
                    <li class="second-menuitem">子菜单项3</li>
                </ul>
            </li>
            <li class="first-menuitem">菜单项4
                <ul class="second-menu">
                    <li class="second-menuitem">子菜单项1</li>
                    <li class="second-menuitem">子菜单项2</li>
                </ul>
            </li>
            <li class="first-menuitem">菜单项5</li>
        </ul>
    </nav>
</body>
</html>